//
//  CYRechargeInProgressViewController.m
//  cyjf
//
//  Created by tauCross on 2017/12/11.
//  Copyright © 2017年 Auto Financing. All rights reserved.
//

#import "CYRechargeInProgressViewController.h"

#import "CYRechargeRecordViewController.h"



@interface CYRechargeInProgressViewController ()

@property(nonatomic, strong)UIImageView *iconImageView;
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *investHintLabel;
@property(nonatomic, strong)UILabel *hintLabel;

@property(nonatomic, strong)UIButton *rechargeRecordButton;

@end


@implementation CYRechargeInProgressViewController

- (void)loadUI
{
    self.navigationItem.title = @"支付处理中";
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.hidden = YES;
    
    self.iconImageView = [[UIImageView alloc] initWithImage:CYImage(@"ico_recharge_processing_green")];
    [self.contentView addSubview:self.iconImageView];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.text = @"银行支付处理中";
    self.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
    self.titleLabel.textColor = HEXCOLOR(@"444444");
    [self.titleLabel sizeToFit];
    [self.contentView addSubview:self.titleLabel];
    
    if(self.type == CYRechargeInProgressTypeInvest)
    {
        self.investHintLabel = [[UILabel alloc] init];
        self.investHintLabel.text = @"注：由于资金处理存在延迟，支付成功后资金会进入账户余额，为您带来的不便，敬请谅解";
        self.investHintLabel.numberOfLines = 0;
        self.investHintLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        self.investHintLabel.textColor = HEXCOLOR(@"999999");
        self.investHintLabel.textAlignment = NSTextAlignmentCenter;
        self.investHintLabel.size = [self.investHintLabel sizeThatFits:CGSizeMake(SCREEN_WIDTH - 80, MAXFLOAT)];
        [self.contentView addSubview:self.investHintLabel];
    }
    
    self.hintLabel = [[UILabel alloc] init];
    self.hintLabel.textColor = HEXCOLOR(@"3E8CE6");
    self.hintLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
    self.hintLabel.text = @"支付结果请稍后查看充值记录";
    [self.hintLabel sizeToFit];
    [self.contentView addSubview:self.hintLabel];
    
    self.rechargeRecordButton = [[UIButton alloc] init];
    self.rechargeRecordButton.layer.masksToBounds = YES;
    self.rechargeRecordButton.layer.cornerRadius = 4;
    self.rechargeRecordButton.layer.borderColor = HEXCOLOR(@"3E8CE6").CGColor;
    self.rechargeRecordButton.layer.borderWidth = 1;
    [self.rechargeRecordButton setTitle:@"查看充值记录" forState:UIControlStateNormal];
    [self.rechargeRecordButton setTitleColor:HEXCOLOR(@"3E8CE6") forState:UIControlStateNormal];
    self.rechargeRecordButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    [self.rechargeRecordButton addTarget:self action:@selector(onRechargeRecordButtonTouchUpInside) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.rechargeRecordButton];
}

- (void)layoutUI
{
    self.iconImageView.centerX = self.contentView.width / 2;
    self.iconImageView.top = 40;
    
    self.titleLabel.centerX = self.contentView.width / 2;
    self.titleLabel.centerY = self.iconImageView.bottom + 28;
    
    if(self.type == CYRechargeInProgressTypeInvest)
    {
        self.investHintLabel.centerX = self.contentView.width / 2;
        self.investHintLabel.top = self.titleLabel.bottom + 15;
        
        self.hintLabel.centerX = self.contentView.width / 2;
        self.hintLabel.top = self.investHintLabel.bottom + 5;
    }
    else
    {
        self.hintLabel.centerX = self.contentView.width / 2;
        self.hintLabel.top = self.titleLabel.bottom + 18;
    }
    
    self.rechargeRecordButton.width = self.contentView.width - 40;
    self.rechargeRecordButton.height = 44;
    self.rechargeRecordButton.centerX = self.contentView.width / 2;
    self.rechargeRecordButton.top = self.hintLabel.bottom + 43;
}

#pragma mark - Control Events
- (void)onRechargeRecordButtonTouchUpInside
{
    CYRechargeRecordViewController *rechargeRecordViewController = [[CYRechargeRecordViewController alloc] init];
    [self.navigationController pushViewController:rechargeRecordViewController animated:YES];
}

@end
